Ext.require(['AM.service.Thumbnails', 'AM.service.Start']);


Ext.define('AM.component.menu.StartMenu', {


    singleton:true,


    getInstance:function () {
        var item1 = {text:'新建', xtype:'button',
            menu:[
                {text:"两行", handler:AM.service.Start.new_2Row },
                {text:"两列", handler:AM.service.Start.new_2Col }
            ]};


        var item3 = {
            iconCls: 'forecolor',
            tooltip: '字体颜色',
            xtype:'button',
            menu:[
                {
                    xtype:'colorpicker',
                    clickEvent:'mousedown',
                    handler:function (cp, color) {
                        color = "#" + color;
                        document.execCommand('ForeColor', false, color);
                        this.up('menu').hide();
                        AM.service.Thumbnails.refresh(ppt.index);
                    }
                }
            ]
        };

        var item4 = {
            iconCls:'backcolor',
            tooltip: '字体背景色',
            xtype:'button',
            menu:[
                {
                    xtype:'colorpicker',
                    clickEvent:'mousedown',
                    handler:function (cp, color) {
                        color = "#" + color;
                        document.execCommand('backcolor', false, color);
                        this.up('menu').hide();
                        AM.service.Thumbnails.refresh(ppt.index);
                    }
                }
            ]
        };


        function btn(text, cmd) {
            return  {
                xtype:'button',
                iconCls:cmd,
                tooltip:text,
                handler:function () {
                    document.execCommand(cmd);
                    AM.service.Thumbnails.refresh(ppt.index);
                }
            }
        }

        var item5 = {
            xtype:'button',
            iconCls: 'increasefont',
            tooltip: '字体大',
            handler: function() {
                var size = document.queryCommandValue('fontsize');
                document.execCommand('FontSize', false, ++size);
                AM.service.Thumbnails.refresh(ppt.index);
            }
        };
        var item52 = {
            xtype:'button',
            iconCls: 'decreasefont',
            tooltip: '字体小',
            handler:function () {
                var size = document.queryCommandValue('fontsize');
                document.execCommand('FontSize', false, --size);
                AM.service.Thumbnails.refresh(ppt.index);
            }
        }

        var item6 = btn('下划线', 'underline');
        var item7 = btn('斜体', 'italic');
        var item8 = btn('粗体', 'bold');
        var item9 = btn('左对齐', 'justifyleft');
        var item10 = btn('居中', 'justifycenter');
        var item11 = btn('右对齐', 'justifyright');
        var item12 = {
            xtype:'button',
            tooltip:'撤销',
            text: '撤销',
            handler:function () {
                document.execCommand('undo');
                AM.service.Thumbnails.refresh(ppt.index);
            }
        }
        var item15 = {
            xtype:'button',
            tooltip:'缩进+',
            text: '缩进+',
            handler:function () {
                document.execCommand('indent');
                AM.service.Thumbnails.refresh(ppt.index);
            }
        }
        var item14 = {
            xtype:'button',
            tooltip:'缩进-',
            text: '缩进-',
            handler:function () {
                document.execCommand('outdent');
                AM.service.Thumbnails.refresh(ppt.index);
            }
        }
        var item16 = btn('无序排列', 'insertunorderedlist');
        var item162 = btn('有序排列', 'insertorderedlist');


        var item13 = {
            xtype:'button',
            text:'字体',
            menu:[
                {xtype:'button', text:'幼圆', handler:function () {
                    document.execCommand('FontName', false, '幼圆');
                    AM.service.Thumbnails.refresh(ppt.index);
                }},
                {xtype:'button', text:'宋体', handler:function () {
                    document.execCommand('FontName', false, '宋体');
                    AM.service.Thumbnails.refresh(ppt.index);
                }},
                {xtype:'button', text:'楷体', handler:function () {
                    document.execCommand('FontName', false, '楷体_GB2312');
                    AM.service.Thumbnails.refresh(ppt.index);
                }}, {
                    xtype:'button', text:'以后丰富'
                }
            ]
        }


        return {
            xtype:'panel',
            title:'开始',
            items:[
                {
                    xtype:'toolbar',
                    items:[item1, '-', item3, item4, item5,item52
                        , item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16,item162
                    ]
                }
            ]
        }
    }



})